/**
 * Created by TRwin7SP1 on 2016/3/11.
 */
var lm = (function () {
  var INTERFACE_NAME = "imagecloud";
  var CURRENT_SERVER = "azureDev";
  var _is = {
    debug: true,
    production: true,
    mobile: false,
    Desktop: true

  }
  //var CURRENT_SERVER = "localDebug";
  // var CURRENT_SERVER = "localServer";
  // var CURRENT_SERVER = "azureDev";

  var _server = function (serverName) {

    var hostUrl = document.location.host;
    var _serverName = serverName || "localhost";
    switch (_serverName) {
      case "hostURL":
        return document.location.host;
        break;
      case "localhost":
        return "http://127.0.0.1";
        break;
      case "localServer104":
        return "http://192.168.100.107";
        break;
      case "publicServer253":
        return "http://123.56.201.253";
        break;
      case "azureDev":
        return "http://139.217.23.117";
        break;
      case "RTlocalserver":
        return "http://192.168.100.111"
        break;
    }
  };

  var _environment = function (environmentName) {
    var _environmentName = environmentName || CURRENT_SERVER;
    var _address = function (serverName, imageCloudPort, hostUrlPort) {
      return {
        imageCloudPort: _server(serverName) + ":" + imageCloudPort,
        imageCloudUrl: _server(serverName) + ":" + imageCloudPort + "/" + INTERFACE_NAME,
        hostUrl: _server(serverName) + ":" + hostUrlPort,
      };
    };
    switch (_environmentName) {
      case "localDebug":
        return _address("localServer104", 8000, 80);
        break;
      case "localServer":
        return _address("localServer104", 8888, 80);
        break;
      case "publishServer":
        return _address("publicServer253", 8888, 80);
        break;
      case "azureDev":
        return _address("azureDev", 8888, 80);
        break;
      case "RTlocalserver":
        return _address("RTlocalserver", 9000,9000);
        break;
    }
  }
  return {
    is: _is,
    environment: _environment,
    server: _server,
  }
})();


// 4种调用模式
// console.log("CURRENT_SERVER:" + JSON.stringify(lm.environment(),null,4));
// console.log("lm.environment().imageCloudPort:" + lm.environment().imageCloudPort);
// console.log("lm.environment().imageCloudUrl:" + lm.environment().imageCloudUrl);
console.log("lm.environment().hostUrl:" + lm.environment("RTlocalserver").hostUrl);
//
// console.log("localDebug:" + JSON.stringify(lm.environment("localDebug"),null,4));
// console.log("localServer:" + JSON.stringify(lm.environment("localServer"),null,4));
// console.log("publishServer:" + JSON.stringify(lm.environment("publishServer"),null,4));


